﻿using Application.DTO;
using Application.DTO.Permission;
using Application.DTO.Syslog;
using Application.IService;
using Application.IService.Permission;
using Application.Service.Permission;
using Domain.Entity.OperationLogD;
using Infrastructure.IRepository.Base;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;


namespace ApiServer.Controllers.OperationLogD
{
    /// <summary>
    /// 日志控制器
    /// </summary>
    [Route("OperationLog")]
    [ApiController]
    public class OperationLogController : BaseController<OperationLog>
    {
        private readonly IOperationLogService baseService;
        public OperationLogController(IBaseService<OperationLog> baseService) : base(baseService)
        {
            this.baseService = (IOperationLogService?)baseService;
        }

    

        /// <summary>
        /// 日志添加
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<IActionResult> OperationLogAdd(OperationLogAddDTO dto)
        {
            return Ok(await baseService.OperationLogAdd(dto));
        }
        /// <summary>
        /// 日志的倒序显示+分页+内容查询
        /// </summary>
        /// <param name="Pagesize"></param>
        /// <param name="Pageindex"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        /// 
        [HttpGet("OperationLog")]
        public async Task<IActionResult> OperationLogReverseOrder(int Pagesize, int Pageindex, string? Content = ""
            //, string StartTime = "", string EndTime = ""
            )
        {
            return Ok(await baseService.OperationLogReverseOrder(Pagesize, Pageindex, Content));
        }


        /// <summary>
        /// 日志的显示+分页+内容查询
        /// </summary>
        /// <param name="Pagesize"></param>
        /// <param name="Pageindex"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<IActionResult> LogShow(int Pagesize, int Pageindex, string? Content = ""
            //, string? StartTime = "", string? EndTime = ""
            )
        {
             return Ok(await baseService.LogShow(Pagesize, Pageindex, Content
                 
                 //,StartTime,EndTime
                 ));
        }

        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        [HttpPost("Add")]
        public async Task<IActionResult> Add(OperationLog operation)
        {
            return Ok(await baseService.Add(operation));
        }


    }
}
